package com.mallcai.bigdata.ladon.dpl.mapper.system;

import com.mallcai.bigdata.ladon.dpl.entity.system.UserRlRole;
import com.mallcai.bigdata.ladon.dpl.mapper.system.provider.UserRlRoleSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface UserRlRoleMapper {

    @InsertProvider(type = UserRlRoleSqlProvider.class, method = "insert")
    public int insert(UserRlRole userRlRole);

    @UpdateProvider(type = UserRlRoleSqlProvider.class, method = "update")
    public int update(UserRlRole userRlRole);

    @UpdateProvider(type = UserRlRoleSqlProvider.class, method = "delete")
    public int delete(UserRlRole userRlRole);

    @Delete({
            "DELETE FROM " + UserRlRoleSqlProvider.TB_USER_RL_ROLE + " WHERE user_id = #{userId}"
    })
    public int deleteByUserId(@Param("userId") Long userId);

    @SelectProvider(type = UserRlRoleSqlProvider.class, method = "hasRole")
    public int hasRole(@Param("userId") Long userId, @Param("roleCode") String roleCode);
}
